08. db.relationship
ND004 C01 L07 08 Model RELATIONSHIPS B-T Todo Lists And Todo Items
Takeaways
- SQLAlchemy configures the settings between model relationships once , and generates JOIN statements for us whenever we need them.
-
db.relationship
is an interface offered in SQLAlchemy to provide and configure a mapped relationship between two models. -
db.relationship
is defined on the parent model, and it sets:-
the name of its children (e.g.
children
), for exampleparent1.children
-
the name of a parent on a child using the
backref
, for examplechild1.my_amazing_parent
-
the name of its children (e.g.